# check diff for alias.csv and pacenote.csv

import pandas as pd
import sqlite3
from loguru import logger

ZTMZ_ALIAES_CSV = '/mnt/c/Users/Admin/lab/ztmz/ztmz_pacenote/src/ZTMZ.PacenoteTool.ScriptEditor/aliases.csv'
ZTMZ_PACENOTE_CSV = '/mnt/c/Users/Admin/lab/ztmz/ztmz_pacenote/src/ZTMZ.PacenoteTool.ScriptEditor/pacenotes.csv'
DB_PATH = '/mnt/c/Users/Admin/lab/ztmz/ztmz_pacenote/src/ZTMZ.PacenoteTool.Base/data.zdb'

def main():
    df_aliases = pd.read_csv(ZTMZ_ALIAES_CSV)
    df_pacenotes = pd.read_csv(ZTMZ_PACENOTE_CSV)

    # check not available token in alias
    conn = sqlite3.connect(DB_PATH)
    c = conn.cursor()
    res = c.execute('SELECT id, primary_filename, filenames FROM pacenote_view')
    pacenotes = res.fetchall()

    # alias column to list
    aliases = df_aliases['Alias'].tolist()
    # token column to list
    tokens = df_aliases['Token'].tolist()
    all = aliases + tokens

    filenames = []
    for id, p_f, p_fs in pacenotes:
        filenames.extend(p_fs.split(','))

    not_available = set(filenames) - set(all)
    logger.info(f'not available: {not_available}')
    
    pass

if __name__ == '__main__':
    main()
